package com.ai.controller.made;


import com.ai.annotation.EnterPathParamLog;
import com.ai.common.CommonResponse;
import com.ai.entity.cameraFunctions.FullFunction;
import com.ai.entity.cameraFunctions.functions.CameraFunctionBindBO;
import com.ai.entity.cameraFunctions.timeInterval.TimeIntervalVO;
import com.ai.entity.made.BaseIdOrNameBO;
import com.ai.service.made.CameraFunctionsService;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * 摄像头方法关系接口
 * @author Mr.Chen
 * @since 2020-11-15
 */
@Slf4j
@RestController
@RequestMapping("/cameraFunctions")
public class CameraFunctionsController {

    @Resource
    private CameraFunctionsService cameraFunctionsService;

    @GetMapping("getFullFunctions")
    @ApiOperation("获取全部功能，以及功能对应的摄像头详细")
    @EnterPathParamLog
    public List<FullFunction> getFullFunctions() {
        return cameraFunctionsService.getFullFunctions();
    }

    @ApiOperation("通过摄像头ID获取两个列表")
    @PostMapping({"cameraFunctionList"})
    @EnterPathParamLog
    public CommonResponse cameraFunctionList(@RequestBody BaseIdOrNameBO baseIdOrNameBO) {
        CommonResponse resultData = this.cameraFunctionsService.cameraFunctionList(baseIdOrNameBO);
        return resultData;
    }

    @ApiOperation("通过摄像头ID提交需要选中的功能列表")
    @PostMapping({"checked"})
    public CommonResponse checked(@RequestBody CameraFunctionBindBO cameraFunctionBindBO) {
        CommonResponse resultData = this.cameraFunctionsService.checked(cameraFunctionBindBO);
        return resultData;
    }

    @ApiOperation("通过摄像头ID提交需要取消的功能列表")
    @PostMapping({"unchecked"})
    public CommonResponse unchecked(@RequestBody CameraFunctionBindBO cameraFunctionBindBO) {
        CommonResponse resultData = this.cameraFunctionsService.unchecked(cameraFunctionBindBO);

        return resultData;
    }

    @ApiOperation("通过摄像头功能关联表主键ID查询时间区间与配置信息")
    @PostMapping({"config"})
    public CommonResponse config(@RequestBody BaseIdOrNameBO baseIdOrNameBO) {
        CommonResponse resultData = this.cameraFunctionsService.config(baseIdOrNameBO);
        return resultData;
    }

    @ApiOperation("通过摄像头功能关联表主键ID查询时间区间与配置信息")
    @PostMapping({"updateConfig"})
    public CommonResponse updateConfig(@RequestBody TimeIntervalVO timeIntervalVO) {
        CommonResponse resultData = this.cameraFunctionsService.updateConfig(timeIntervalVO);
        return resultData;
    }

    @ApiOperation("通过功能ID获取摄像头列表信息")
    @PostMapping({"listCameraByFunction"})
    public CommonResponse listCameraByFunction(@RequestBody BaseIdOrNameBO baseIdOrNameBO) {
        CommonResponse resultData = this.cameraFunctionsService.listCameraByFunction(baseIdOrNameBO);
        return resultData;
    }
}

